package com.huawei.hms.support.api.pay.json;

import android.app.PendingIntent;
import android.os.Parcelable;
import com.huawei.hms.common.ApiException;
import com.huawei.hms.common.internal.ResponseErrorCode;
import com.huawei.hms.common.internal.TaskApiCall;
import com.huawei.hms.support.api.client.Status;
import com.huawei.hms.support.api.entity.pay.PayResp;
import com.huawei.hms.support.api.pay.PayResult;
import com.huawei.hms.support.hianalytics.HiAnalyticsClient;
import com.huawei.hms.support.log.HMSLog;
import com.huawei.hms.utils.JsonUtil;
import o.fjx;

public class PayTaskApiCall extends TaskApiCall<PayHmsClient, PayResult> {
    public PayTaskApiCall(String str, String str2, String str3) {
        super(str, str2, str3);
    }

    protected void doExecute(PayHmsClient payHmsClient, ResponseErrorCode responseErrorCode, String str, fjx<PayResult> o_fjx_com_huawei_hms_support_api_pay_PayResult) {
        if (responseErrorCode == null) {
            o_fjx_com_huawei_hms_support_api_pay_PayResult.ॱ(new ApiException(new Status(1)));
            return;
        }
        HiAnalyticsClient.reportExit(payHmsClient.getContext(), getUri(), getTransactionId(), responseErrorCode.getStatusCode(), responseErrorCode.getErrorCode());
        if (responseErrorCode.getErrorCode() == 0) {
            PendingIntent pendingIntent;
            HMSLog.i("PayTaskApiCall", "onResult, success");
            Object payResp = new PayResp();
            JsonUtil.jsonToEntity(str, payResp);
            PayResult payResult = new PayResult();
            Parcelable parcelable = responseErrorCode.getParcelable();
            if (parcelable instanceof PendingIntent) {
                pendingIntent = (PendingIntent) parcelable;
            } else {
                pendingIntent = null;
            }
            payResult.setStatus(new Status(payResp.retCode, null, pendingIntent));
            o_fjx_com_huawei_hms_support_api_pay_PayResult.ॱ(payResult);
            return;
        }
        HMSLog.i("PayTaskApiCall", "onResult, returnCode: " + responseErrorCode.getErrorCode());
        o_fjx_com_huawei_hms_support_api_pay_PayResult.ॱ(new ApiException(new Status(responseErrorCode.getErrorCode(), responseErrorCode.getErrorReason())));
    }
}
